package com.itheima.employee.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.employee.mapper.UserCompanyPersonalMapper;
import com.itheima.employee.pojo.UserCompanyPersonal;
import com.itheima.employee.pojo.vo.EmployeeReportVo;
import com.itheima.employee.service.UserCompanyPersonalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author qiankaofei
 * @version 1.0
 * @date 2020/11/16 10:45
 */
@Service
@Transactional
public class UserCompanyPersonalServiceImpl implements UserCompanyPersonalService {
    @Autowired
    private UserCompanyPersonalMapper userCompanyPersonalMapper;

    /**
     *  员工个人信息保存
     *
     */
    public Integer save(UserCompanyPersonal personalInfo) {
        return userCompanyPersonalMapper.insert(personalInfo);
    }

    /**
     * 员工个人信息读取
     */
    public UserCompanyPersonal findById(String userId) {
        QueryWrapper<UserCompanyPersonal> wrapper=new QueryWrapper<UserCompanyPersonal>();
        wrapper.eq("user_id",userId);
        return userCompanyPersonalMapper.selectOne(wrapper);
    }

    @Override
    public List<EmployeeReportVo> exportEmPersonal(String companyId,String month) {
        return userCompanyPersonalMapper.exportEmPersonal(companyId,month);
    }
}
